//
//  TCLYTieZiTableViewCell.m
//  YuErmuYing
//
//  Created by LYang on 16/8/19.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYTieZiTableViewCell.h"
#import "Masonry.h"
#import "Macros.h"

@implementation TCLYTieZiTableViewCell
-(instancetype) initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1];
        UIImageView * bgImageView = [[UIImageView alloc] init];
        bgImageView.backgroundColor = [UIColor whiteColor];
        [self addSubview:bgImageView];
        [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(6);
            make.left.mas_equalTo(self);
            make.right.mas_equalTo(self);
            make.bottom.mas_equalTo(-6);
        }];
        //头像
        self.headerImageView = [[UIImageView alloc] init];
        self.headerImageView.layer.cornerRadius = 15;
        self.headerImageView.layer.masksToBounds = YES;
        [self addSubview:self.headerImageView];
        [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.mas_left).offset(12);
            make.top.mas_equalTo(self.mas_top).offset(12);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(30);
        }];
        //昵称
        self.nickNameLabel = [[UILabel alloc] init];
        self.nickNameLabel.font = [UIFont systemFontOfSize:12];
        self.nickNameLabel.textColor = [UIColor lightGrayColor];
        self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.nickNameLabel];
        [self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.headerImageView);
            make.left.mas_equalTo(self.headerImageView.mas_right).offset(12);
            make.right.mas_equalTo(self.mas_right).offset(-12);
            make.height.mas_equalTo(20);
        }];
        //标题
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        self.titleLabel.textColor = [UIColor blackColor];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.titleLabel];
        //内容
        self.contentLabel = [[UILabel alloc] init];
        self.contentLabel.font = [UIFont systemFontOfSize:12];
        self.contentLabel.textColor = [UIColor blackColor];
        self.contentLabel.textAlignment = NSTextAlignmentLeft;
        self.contentLabel.numberOfLines = 0;
        [self addSubview:self.contentLabel];
        
        //显是时间的label
        self.timeLabel = [[UILabel alloc] init];
        self.timeLabel.font = [UIFont systemFontOfSize:10];
        self.timeLabel.textColor = grayFont;
        self.timeLabel.textAlignment = NSTextAlignmentLeft;
        self.timeLabel.numberOfLines = 1;
        [self addSubview:self.timeLabel];
        

        
        
        //显示赞同的label
        self.agreedLabel =[[UILabel alloc] init];
        self.agreedLabel.font = [UIFont systemFontOfSize:10];
        self.agreedLabel.textColor = grayFont;
        [self addSubview:self.agreedLabel];
        [self.agreedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(6);
            make.left.mas_equalTo(12);
            make.width.mas_equalTo(80/375.0*screenWidth);
            make.height.mas_equalTo(20);
        }];
        
//        if ([self.contentLabel.text isEqual:@""]) {
//            self.agreedLabel =[[UILabel alloc] init];
//            self.agreedLabel.font = [UIFont systemFontOfSize:10];
//            self.agreedLabel.textColor = grayFont;
//            [self addSubview:self.agreedLabel];
//            [self.agreedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.mas_equalTo(self.titleLabel);
//                make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(6);
//                make.width.mas_equalTo(80);
//                make.height.mas_equalTo(20);
//            }];
//        }else{
//            self.agreedLabel =[[UILabel alloc] init];
//            self.agreedLabel.font = [UIFont systemFontOfSize:10];
//            self.agreedLabel.textColor = grayFont;
//            [self addSubview:self.agreedLabel];
//            [self.agreedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.left.mas_equalTo(self.contentLabel);
//                make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(6);
//                make.width.mas_equalTo(80);
//                make.height.mas_equalTo(20);
//            }];
//        }
        
        self.commentsLabel = [[UILabel alloc] init];
        
        self.commentsLabel.font = [UIFont systemFontOfSize:10];
        self.commentsLabel.textColor = grayFont;
        self.commentsLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.commentsLabel];
        [self.commentsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.agreedLabel.mas_right).offset(12);
            make.top.mas_equalTo(self.agreedLabel);
            make.width.mas_equalTo(80/375.0*screenWidth);
            make.height.mas_equalTo(20);
        }];
        
        
        UILabel * delete = [[UILabel alloc] init];
        delete.font = [UIFont systemFontOfSize:12];
        delete.textColor = grayFont;
        delete.text = @"删除";
        delete.textAlignment = NSTextAlignmentCenter;
        [self addSubview:delete];
        [delete mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.mas_right).offset(-6);
            make.top.mas_equalTo(self.commentsLabel);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(30);
        }];
        
        self.deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.deleteBtn setImage:[UIImage imageNamed:@"mineDelete"] forState:UIControlStateNormal];
        [self addSubview:self.deleteBtn];
        [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(delete.mas_left).offset(-6);
            make.height.mas_equalTo(20);
            make.top.mas_equalTo(self.commentsLabel);
            make.width.mas_equalTo(30);
        }];
        
        UILabel * editor = [[UILabel alloc] init];
        editor.text = @"编辑";
        editor.textAlignment = NSTextAlignmentCenter;
        editor.font = [UIFont systemFontOfSize:12];
        editor.textColor = grayFont;
        [self addSubview:editor];
        [editor mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(delete);
            make.right.mas_equalTo(self.deleteBtn.mas_left).offset(-10);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(20);
        }];
        
        self.editorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.editorBtn setImage:[UIImage imageNamed:@"mineEdit"] forState:UIControlStateNormal];
        [self addSubview:self.editorBtn];
        [self.editorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(editor.mas_left).offset(-6);
            make.top.mas_equalTo(self.deleteBtn);
            make.width.mas_equalTo(30);
            make.height.mas_equalTo(20);
        }];
        
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
